Unable to load directory when using jar [on hold]

Posted by user1630359 on Super User See other posts from Super User or by user1630359
Published on 2013-10-28T09:41:59Z Indexed on 2013/10/28 9:56 UTC
Read the original article Hit count: 87

Filed under:

I've a directory in my eclipse project, in build path which contains files (txt).

Now, when i run the application from eclipse, i can read the files (using #1 below). but, when i export my application to jar and run it from other pc i can't read the files or even check whether the directory exist or not.

All the below lines are always return NULL!

1. File dir = new File("files");
2. File dir = this.getClass().getResourceAsStream("files");
3. File dir = this.getClass().getClassLoader().getResource("files");

any assistance will be appreciated!

Thanks!

© Super User or respective owner

Related posts about java